package cmd

import (
	"cke.io/ckectl/app/cmd/ckectl/component"
	"io"

	ckectl "cke.io/ckectl/app/cmd/ckectl"
	"github.com/spf13/cobra"
)

// NewCkectlCommand returns cobra.Command to run ckectl command
func NewCkectlCommand(in io.Reader, out, err io.Writer) *cobra.Command {

	cmds := &cobra.Command{
		Use:   "ckectl",
		Short: "",
		Long:  "",

		PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
			return nil
		},
	}

	// ckectl cmd for cke up, install, uninstall, scale, scaledown
	cmds.AddCommand(ckectl.NewCmdPrepare(out, nil))   // prepare before start
	cmds.AddCommand(ckectl.NewCmdUp(out, nil))        // up cluster
	cmds.AddCommand(ckectl.NewCmdScale(out, nil))     // scale cluster
	cmds.AddCommand(ckectl.NewCmdScaleDown(out, nil)) // scale-down
	cmds.AddCommand(ckectl.NewCmdUpgrade(out, nil))   // upgrade
	cmds.AddCommand(ckectl.NewCmdWatch(out, nil))     // watch up for install

	cmds.AddCommand(component.NewCmdComponent())
	cmds.AddCommand(ckectl.NewCmdTemplate())

	return cmds
}
